/**
 * Created by pan on 2018年02月07日14:25:32.
 */
const express = require('express');
const router = express.Router();
const superagent = require('superagent');

router.get('/', async function(req, res, next) {
    superagent
        .get('http://api.zhuishushenqi.com/ranking/gender')
        .end(function(err, response) {
            if (err) {
                res.send({
                    result: 0,
                    msg: err,
                });
            } else {
                try {
                    const result = JSON.parse(response.text);
                    const { male, female } = result;
                    res.send({
                        result: 1,
                        data: { male: male, female: female },
                    });
                } catch (e) {
                    res.send({
                        result: 1,
                        data: e.toString(),
                    });
                }
            }
        });
});

module.exports = router;
